<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        let number = 18
        let Person = {
            name:'Tom',
            gender:'male',
        }

        Object.defineProperty(Person,'age',{
            // value:18,
            // enumerable:true, // 控制属性是否可以枚举，默认值是false
            // writable:true, // 控制属性是否可以修改，默认是false
            // configurable:true, // 控制属性是否可以被删除，默认是false
            get(){
                console.log('你获取了值')
                return number
            },
            set(value){
                console.log('你更改了值,值是',value)
                number = value
            }
        })

        console.log(Person)
    </script>
</body>
</html>